package com.me.customerdemo.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.me.customerdemo.dao.SalesChanncesMapper;
import com.me.customerdemo.pojo.SalesChannces;
import com.me.customerdemo.service.SalesChanncesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


import java.util.List;

@Service
public class SalesChanncesServerImpl implements SalesChanncesService {

    @Autowired
    private SalesChanncesMapper salesChanncesMapper;

    @Override
    public List<SalesChannces> selectAll() {
        return salesChanncesMapper.selectAll();
    }

    @Override
    public PageInfo<SalesChannces> findByKeyword(int pageNum, int pageSize, String keyword) {
        PageHelper.startPage(pageNum,pageSize);
        List<SalesChannces> productTypes = salesChanncesMapper.selectByKeyword(keyword);
        PageInfo<SalesChannces> page = new PageInfo<>(productTypes);
        return page;
    }

    @Override
    public SalesChannces findById(int id) {
        return salesChanncesMapper.selectById(id);
    }

    @Override
    public boolean updateById(SalesChannces salesChannces) {
        return salesChanncesMapper.updateById(salesChannces)>0? true:false;
    }

    @Override
    public boolean deleteById(int id) {
        return salesChanncesMapper.deleteById(id)>0?true:false;
    }

    @Override
    public boolean apply(SalesChannces salesChannces) {
        return salesChanncesMapper.apply(salesChannces)>0?true:false;
    }



    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean modify(SalesChannces customer) {
        return salesChanncesMapper.updateById(customer) > 0;
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean removeById(int id) {
        return salesChanncesMapper.deleteById(id) > 0;
    }
}
